/**
 * Created with JetBrains PhpStorm.
 * User: vander
 * Date: 5/18/13
 * Time: 12:15 AM
 * To change this template use File | Settings | File Templates.
 */
var UndoRedo = Class.create({
    initialize: function(){
        this.undoStack = new Array();
        this.redoStack = new Array();


    },
    pushUndoStack: function(action, data, isPushByRedo){
        var o = new Object();
        o['action'] = action;
        o['data'] = data;
        this.undoStack.push(o);

        //Thuc hien mot thao tac khong phai redo thi clear sach redo de tranh bug
        if(isPushByRedo == undefined){
            this.redoStack.clear();
        }
    },
    popUndoStack: function(){
        return this.undoStack.pop();
    },
    pushRedoStack: function(action, data){
        this.redoStack.push({action: action, data:data});
    },
    popRedoStack: function(){
        return this.redoStack.pop();
    },
    clear: function(){
        this.undoStack = new Array();
        this.redoStack = new Array();
    }
});